<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of ToolsController
 *
 * @author Administrator
 */
class ToolsController extends Controller {
    public $model;
    public function actionConfig() {
        $model = new Config();
        $this->performAjaxValidation($model);
        if( Yii::app()->request->isPostRequest){
            $model->attributes = Yii::app()->request->getPost('Config');
            if($model->save()){
                $this->redirect($this->createUrl('config'));
            }
        }
        $this->model= $model;
        $this->render('config', array('model' => $this->model));
    }
    protected function performAjaxValidation($model) {
        if (isset($_POST['ajax']) && $_POST['ajax'] === 'config-form') {
            echo CActiveForm::validate($model);
            Yii::app()->end();
        }
    }

}

?>
